import os

# 返回绝对路径
print(os.path.abspath(r'/python_230901/homework/wuyuan/day1229/1_ddt/baidu.png'))
# 返回文件名
print(os.path.basename(r'C:\Users\hp\PycharmProjects\python_230901\homework\wuyuan\day1229\baidu.png'))
# 返回所在目录
print(os.path.dirname(r'C:\Users\hp\PycharmProjects\python_230901\homework\wuyuan\day1229\baidu.png'))
# 返回当前文件的绝对路径
print(os.path.abspath(__file__))
# 返回当前文件的文件名
print(os.path.basename(__file__))
# 返回当前文件的所在目录
print(os.path.dirname(__file__))
